import request from '@/utils/request'

const BASE_URL = 'plan/'
const LIST_URL = BASE_URL
const READ_URL = BASE_URL
const CREATE_URL = BASE_URL
const UPDATE_URL = BASE_URL
const DELETE_URL = BASE_URL

export function getPlanList(params) {
  return request({
    url: LIST_URL,
    method: 'get',
    params: params
  })
}

export function getPlan(id) {
  return request({
    url: READ_URL + id + '/',
    method: 'get'
  })
}

export function createPlan(data) {
  return request({
    url: CREATE_URL,
    method: 'post',
    data: data
  })
}

export function updatePlan(id, data) {
  return request({
    url: UPDATE_URL + id + '/',
    method: 'patch',
    data: data
  })
}

export function deletePlan(id) {
  return request({
    url: DELETE_URL + id + '/',
    method: 'delete'
  })
}

export function executePlan(id) {
  return request({
    url: BASE_URL + id + '/execute/',
    method: 'post'
  })
}

export function getPlanCount() {
  return request({
    url: BASE_URL + 'count/',
    method: 'get'
  })
}
